var t1 =  setInterval(function(){
    var bloodObj = document.querySelector('.blood')
    var bloodWidth = parseInt(bloodObj.style.width)
    bloodWidth -=5
    bloodObj.style.width = bloodWidth + 'px'
    if(bloodWidth==-5){
        clearInterval(t1)
        clearInterval(t2)
        alert('You are default')
    }
},1000)
var btnObj = document.querySelector('button')
btnObj.onclick = function () {
    var bloodObj = document.querySelector('.blood')
    bloodObj.style.width = '200px'
    var bloodWidth = parseInt(bloodObj.style.width)

}
function random(min,max){
    return Math.floor(Math.random()*(max-min+1)+min)
}

//每一秒随机出现一个星星
var t2 = setInterval(function(){
    var imgObj = document.createElement('img')
    imgObj.src = './star.gif'
    var min = 20
    var max = 100
    imgObj.width = random(min,max)
    imgObj.style.position = 'absolute'
    var min2 = 0
    var max2 =( window.innerWidth ||document.documentElement.clientWidth)-imgObj.width
    imgObj.style.left = random(min2,max2)
    var max3 = ( window.innerHeight ||document.documentElement.clientHeight)-imgObj.width
    imgObj.style.top =  random(min2,max3)
    document.body.appendChild(imgObj)
},1000)

//删除星星
var bodyObj = document.body
bodyObj.onclick =  function(evt){
    var e =evt||window.event
    var target = e.target||e.srcElement
    if(target.nodeName ==='IMG'){
        bodyObj.removeChild(target)
    }
}